import request from './http'
export function getBillList(type,size=6,offset=0){
    const url=`/api/v1/restserver/ting/baidu.ting.billboard.billList?method=baidu.ting.billboard.billList&type=${type}&size=${size}&offset=${offset}`
        return request.get(url).then(res=>{
            return {
                ...res,
                list:res.song_list
            }
    })
}

// 课程列表
function getCourse(type,pageNum,pageSize){
    const params  = new URLSearchParams();
    params.append('type', type)
    params.append('pageSize', pageSize)
    params.append('pageNum',pageNum)
    const url = `/api/weChat/applet/course/list/type`
    return request.post(url,params)
}
// export function getMusicDetail(songId){
//     const url=`/api/v1/restserver/ting/baidu.ting.billboard.billList?method=baidu.ting.billboard.billList&type=${this.type}&size=${this.size}&offset=0`
//     return request.get(url)
//         }
//轮播图
function  getSwiper(number=5){
    const url = `/api/weChat/applet/course/banner/list?number=${number}`
    return request.get(url)
}
//友情链接
function links(dictType='blogroll',pageSize=10,pageNum=1,orderByColumn='dictSort',isAsc='asc'){
    const params = new URLSearchParams();
    params.append("dictType", dictType);
    params.append("pageSize", pageNum);
    params.append("pageSize", pageSize);
    params.append("orderByColumn", orderByColumn);
    params.append("isAsc", isAsc);
    const url = `/api/system/dict/data/list/open`
    return request.post(url,params)
}
// 列表
function getCourseDetail(courseId){
    const url =`/api/pc/course/detail/${courseId}`
    return request.get(url)

}
function getShopping(status=1) {
    const  url=`/api/weChat/applet/shoppingCart/my/list?status=${status}`
    return request.get(url);
}
// 添加购物车数据
function addShopping(courseId) {
    const  url=`/api/weChat/applet/shoppingCart/join/shoppingCart/${courseId}`
    return request.get(url);
}
// 删除数据
function delShopping(shoppingCartId) {
    const  url=`/api/weChat/applet/shoppingCart/remove/${shoppingCartId}`
    return request.get(url);
}

// 登录接口
function loginDetail(username,password,rememberMe =true) {
    const params = new URLSearchParams();
    params.append("username", username);
    params.append("password", password);
    params.append("rememberMe", rememberMe);
    const url = `/api/pcUser/login`
    return request.post(url, params)
}
//退出登录状态
function logOutLogin(){
    let url=`/api/pcUser/logout`
    return request.get(url)
}

//路由拦截个人信息接口
function peopleMessage(){
    let url=`/api/pcUser/login-user/info`
    return request.get(url)
}

export {getCourse ,getSwiper,links,getCourseDetail,getShopping,delShopping,addShopping,loginDetail,logOutLogin,peopleMessage}